function plot_dendro

global clust oldclust a dates1 dates2 cumnums clustratio uniqratio neoratio endratio fieldedit hpp hp butt
if exist('../tmp/plot_NNK.mat','file')== 2;    load ../tmp/plot_NNK.mat ;end
if size(clust,1) == 0 ;     plot_dendro_0 ; end
hpp=[];a=[];

if exist('pathname','var')==1;if ischar(pathname) == 1
        % affiche infos %%%%%%%%%%%%%%%%
        disp('Plot dendrogram') ;
        disp('Module plot_dendro  ...')

        resizeeffect(fh,bar1)
        clf(fh,'reset');[th,hp,pth]=plot_NNKtools(fh,backcolor,bar1);%a = axes('parent',hp(2),'Layer','top');
        resizeeffect(fh,bar2)
        
        [fieldedit]=timeselector(hp(1),0,19.3/20,1,2/30);

                
        uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[0 10/20 1/4 1/20], ...
            'CData',geticon('dendo'),'TooltipString','Plot the dendrogram', ...
            'Callback','plot_dendro_1(1)');
        uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[1/4 10/20 1/4 1/20], ...
            'CData',geticon('order'),'TooltipString','invert cluster sorting order', ...
            'Callback','plot_inverted');
        uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[2/4 10/20 1/4 1/20], ...
            'CData',geticon('cumulclust'),'TooltipString','Plot cumulate number of cluster', ...
            'Callback','plot_dendro_1(2)');
        uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[3/4 10/20 1/4 1/20], ...
            'String','R/t','TooltipString','Plot the ratios of repeating earthquake (and unique)', ...
            'Callback','plot_dendro_1(7)');
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[0 9/20 1/4 1/20], ...
            'CData',geticon('cumuls'),'TooltipString','Plot the cumulate seismicities', ...
            'Callback','plot_dendro_1(3)');
        uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[1/4 9/20 1/4 1/20], ...
            'CData',geticon('derivcumuls'),'TooltipString','Plot the derivates of the cumulate seismicities', ...
            'Callback','plot_dendro_1(4)');
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[0 8/20 1/4 1/20], ...
            'CData',geticon('startNend'),'TooltipString','Plot the cumulate number of starting and ending clusters', ...
            'Callback','plot_dendro_1(5)');
        uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[1/4 8/20 1/4 1/20], ...
            'CData',geticon('startNendderiv'),'TooltipString','Plot the derivates of the cumulate number of starting and ending clusters', ...
            'Callback','plot_dendro_1(6)');
        uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[3/4 8/20 1/4 2/20], ...
            'String','off','TooltipString','Toogle (resampling on & smothing on)|(resampling on & smothing off)|(resampling off & smothing off)', ...
            'Callback','load ../tmp/plot_NNK.mat;if length(param)<9;param(9)=0;end;param(9)=param(9)+1;if param(9)==3;param(9)=0;end;save ../tmp/plot_NNK.mat param -append');
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[0 7/20 1/4 1/20], ...
            'CData',geticon('clusterwf'),'TooltipString','Pick a cluster on dendrogram and plot waveforms', ...
            'Callback','dendro2wfs;');
        uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[1/4 7/20 1/12 1/20], ...
            'String','A','TooltipString','Take the cluster on dendrogram and make amplitude vs time plot', ...
            'Callback','dendro2amptime;');
        uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[1.3/4 7/20 1/12 1/20], ...
            'String','M','TooltipString','Take the cluster on dendrogram and make magnitude vs time plot', ...
            'Callback','dendro2magtime;');
        uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[1.6/4 7/20 1/12 1/20], ...
            'String','b','TooltipString','Take the cluster on dendrogram and make b-value plot', ...
            'Callback','dendro2bval;');        
        uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[2/4 7/20 1/4 1/20], ...
            'String','T','TooltipString','Take the cluster on dendrogram and make a Taisne model', ...
            'Callback','dendro2creation;');
        uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[3/4 7/20 1/4 1/20], ...
            'String','+','TooltipString','plot a GPS .pos file', ...
            'Callback','plot_GPSinNNK;')
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[0 6/20 1/4 1/20], ...
            'CData',geticon('hist'),'TooltipString','Plot the inter-hypocenter distancies', ...
            'Callback','plot_reloc_1(1)');
        uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[1/4 6/20 1/4 1/20], ...
            'CData',geticon('rms'),'TooltipString','Plot the RMS', ...
            'Callback','plot_reloc_1(2)');   
        uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[2/4 6/20 1/4 1/20], ...
            'CData',geticon('obs'),'TooltipString','Plot the observations', ...
            'Callback','plot_reloc_1(3)');
        uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[3/4 6/20 1/4 1/20], ...
            'CData',geticon('plotmap'),'TooltipString','Map the earthquakes', ...
            'Callback','plot_EQ_1(5)');
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[0 5/20 1/4 1/20], ...
            'CData',geticon('ploteq'),'TooltipString','Plot the earthquakes in map and section', ...
            'Callback','plot_EQ_1(1)');
        uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[1/4 5/20 1/4 1/20], ...
            'CData',geticon('plotdens'),'TooltipString','Plot the density maps and section', ...
            'Callback','plot_EQ_1(3)');
        uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[2/4 5/20 1/4 1/20], ...
            'CData',geticon('plotdensmap'),'TooltipString','Plot the density maps by Z slices', ...
            'Callback','plot_EQ_1(2)');
        uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[3/4 5/20 1/4 1/20], ...
            'CData',geticon('plotdensiso'),'TooltipString','Plot the density isosurfaces', ...
            'Callback','plot_EQ_1(4)');
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[0 4/20 1/4 1/20], ...
            'CData',geticon('clustersrc'),'TooltipString','Pick a cluster on map', ...
            'Callback','map2source');
        butt(1)=uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[1/4 4/20 1/8 1/20], ...
            'String','[t]','TooltipString','Pick a time period file', ...
            'Callback','get_timeperiod(''investigationperiods'',1,''[t]'')');
        butt(2)=uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[1.5/4 4/20 1/8 1/20], ...
            'String',']t[','TooltipString','Pick a time period file', ...
            'Callback','get_timeperiod(''excludeperiods'',2,'']t['')');
        butt(3)=uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[2/4 4/20 1/4 1/20], ...
            'String','U','TooltipString','Disable unique earthquakes', ...
            'Callback','load ../tmp/membutton.mat;if strcmp(get(butt(3),''String''),''U'')==1;set(butt(3),''String'',''no U'',''TooltipString'',''Enable unique earthquakes'');else;set(butt(3),''String'',''U'',''TooltipString'',''Disable unique earthquakes'');end');
        save ../tmp/membutton.mat butt
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[3/4 4/20 1/4 1/20], ...
            'CData',geticon('plotdens'),'TooltipString','Plot the clustering ratio map', ...
            'Callback','plot_EQanim(1)')
        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        uicontrol('Parent',hp(1),'Style','pushbutton','Units','normalized', ...
            'Position',[0 3/20 1/4 1/20], ...
            'String','S','TooltipString','make a cross section on current map', ...
            'Callback','map2section');
        
        save ../tmp/plot_NNK.mat fieldedit hp th fieldedit a -append
        

    else disp('Please choose path before that') ;        
    end
else disp('Please choose path before that') ;
end
end

    

%         uicontrol('Parent',hp(1), ...
%             'Style','pushbutton', ...
%             'Units','normalized', ...
%             'Position',[0 28/30 1 1/30], ...
%             'String','Dendrogram & Seismicity', ...
%             'TooltipString','Plot the dendrogram and the cumulate seismicity', ...
%             'Callback','plot_dendro_2(1)');
%         
% %         uicontrol('Parent',hp(1), ...
% %             'Style','pushbutton', ...
% %             'Units','normalized', ...
% %             'Position',[0 27/30 1 1/30], ...
% %             'String','Dendrogram & Neo-seismicity', ...
% %             'TooltipString','Plot the dendrogram and the ratio of new clusters', ...
% %             'Callback','plot_dendro_2(2)');
%                
%         uicontrol('Parent',hp(1), ...
%             'Style','pushbutton', ...
%             'Units','normalized', ...
%             'Position',[0 27/30 1 1/30], ...
%             'String','New & ending clusters ', ...
%             'TooltipString','Plot the dendrogram, and both the ratio of new clusters and of ending clusters', ...
%             'Callback','plot_dendro_2(3)');
%         
%         uicontrol('Parent',hp(1), ...
%             'Style','pushbutton', ...
%             'Units','normalized', ...
%             'Position',[0 26/30 1 1/30], ...
%             'String','Clustered & uniq eq.', ...
%             'TooltipString','Plot the dendrogram, and both the ratio of clustered earthquakes and of unique earthquakes', ...
%             'Callback','plot_dendro_2(4)');
%         
%         uicontrol('Parent',hp(1), ...
%             'Style','pushbutton', ...
%             'Units','normalized', ...
%             'Position',[0 25/30 1 1/30], ...
%             'String','New-ending clust. & clust. eq.', ...
%             'TooltipString','Plot the dendrogram, the ratio of new clusters, of ending clustersthe ratio and of clustered earthquakes', ...
%             'Callback','plot_dendro_2(5)');
%         
%         uicontrol('Parent',hp(1), ...
%             'Style','pushbutton', ...
%             'Units','normalized', ...
%             'Position',[0 24/30 1 1/30], ...
%             'String','New-ending clust. & uniq. eq.', ...
%             'TooltipString','Plot the dendrogram, the ratio of new clusters, of ending clustersthe ratio and of unique earthquakes', ...
%             'Callback','plot_dendro_2(6)');
%         
%         
%         uicontrol('Parent',hp(1), ...
%             'Style','pushbutton', ...
%             'Units','normalized', ...
%             'Position',[0 20/30 1 1/30], ...
%             'String','Dendro to waveforms', ...
%             'TooltipString','Pick a cluster on dendrogram and plot waveforms', ...
%             'Callback','dendro2wfs;');
%         
%         uicontrol('Parent',hp(1), ...
%             'Style','pushbutton', ...
%             'Units','normalized', ...
%             'Position',[0 19/30 1 1/30], ...
%             'String','Normalized creation rate', ...
%             'TooltipString','Pick a cluster on dendrogram and plot waveforms', ...
%             'Callback','dendro2creation;');



